.class public Les/u9;
.super Ljava/lang/Object;
.source "MediaExtractorWrapper.java"

# interfaces
.implements Ljava/lang/Runnable;
.implements Lcom/esfile/screen/recorder/media/util/m;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Les/u9$a;
    }
.end annotation


# instance fields
.field private a:Landroid/media/MediaExtractor;

.field private final b:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Lcom/esfile/screen/recorder/media/util/l;",
            ">;"
        }
    .end annotation
.end field

.field private c:Ljava/lang/String;

.field private d:Z

.field private e:Z

.field private f:Z

.field private g:J

.field private h:J

.field private i:I

.field private j:Z

.field private k:Les/u9$a;


# direct methods
.method public constructor <init>(Ljava/lang/String;Z)V
    .locals 3

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 2
    new-instance v0, Ljava/util/ArrayList;

    const/4 v1, 0x3

    invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(I)V

    iput-object v0, p0, Les/u9;->b:Ljava/util/List;

    const/4 v0, 0x0

    .line 3
    iput-boolean v0, p0, Les/u9;->e:Z

    .line 4
    iput-boolean v0, p0, Les/u9;->f:Z

    const-wide/16 v1, -0x1

    .line 5
    iput-wide v1, p0, Les/u9;->g:J

    .line 6
    iput-wide v1, p0, Les/u9;->h:J

    .line 7
    iput-boolean v0, p0, Les/u9;->j:Z

    .line 8
    iput-object p1, p0, Les/u9;->c:Ljava/lang/String;

    .line 9
    iput-boolean p2, p0, Les/u9;->d:Z

    .line 10
    new-instance p1, Landroid/media/MediaExtractor;

    invoke-direct {p1}, Landroid/media/MediaExtractor;-><init>()V

    iput-object p1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    return-void
.end method

.method private declared-synchronized c()V
    .locals 1

    monitor-enter p0

    const/4 v0, 0x0

    .line 1
    :try_start_0
    iput-boolean v0, p0, Les/u9;->e:Z

    .line 2
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    if-eqz v0, :cond_0

    .line 3
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {v0}, Landroid/media/MediaExtractor;->release()V

    const/4 v0, 0x0

    .line 4
    iput-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 5
    :cond_0
    monitor-exit p0

    return-void

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method


# virtual methods
.method public a(JJI)J
    .locals 4

    .line 26
    iget-boolean v0, p0, Les/u9;->f:Z

    if-eqz v0, :cond_5

    .line 27
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    if-eqz v0, :cond_4

    const/4 v0, 0x1

    const/4 v1, 0x2

    if-eq p5, v1, :cond_0

    if-eq p5, v0, :cond_0

    if-eqz p5, :cond_0

    const/4 p5, 0x2

    :cond_0
    const-wide/16 v2, 0x0

    .line 28
    invoke-static {p1, p2, v2, v3}, Ljava/lang/Math;->max(JJ)J

    move-result-wide v2

    iput-wide v2, p0, Les/u9;->g:J

    .line 29
    iput-wide p3, p0, Les/u9;->h:J

    .line 30
    iput p5, p0, Les/u9;->i:I

    .line 31
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p3, p1, p2, p5}, Landroid/media/MediaExtractor;->seekTo(JI)V

    .line 32
    iget p3, p0, Les/u9;->i:I

    if-nez p3, :cond_3

    iget-boolean p3, p0, Les/u9;->d:Z

    if-nez p3, :cond_3

    .line 33
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p3}, Landroid/media/MediaExtractor;->getSampleTime()J

    move-result-wide p3

    cmp-long p5, p3, p1

    if-lez p5, :cond_1

    .line 34
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p3, p1, p2, v0}, Landroid/media/MediaExtractor;->seekTo(JI)V

    .line 35
    :cond_1
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p3}, Landroid/media/MediaExtractor;->getSampleTime()J

    move-result-wide p3

    cmp-long p5, p3, p1

    if-lez p5, :cond_2

    .line 36
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p3, p1, p2, v1}, Landroid/media/MediaExtractor;->seekTo(JI)V

    .line 37
    :cond_2
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p3}, Landroid/media/MediaExtractor;->getSampleTime()J

    move-result-wide p3

    cmp-long p5, p3, p1

    if-lez p5, :cond_3

    .line 38
    iget-object p3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    const/4 p4, 0x0

    invoke-virtual {p3, p1, p2, p4}, Landroid/media/MediaExtractor;->seekTo(JI)V

    .line 39
    :cond_3
    iget-object p1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {p1}, Landroid/media/MediaExtractor;->getSampleTime()J

    move-result-wide p1

    return-wide p1

    .line 40
    :cond_4
    new-instance p1, Ljava/lang/IllegalStateException;

    const-string p2, "MediaExtractorWrapper has been released"

    invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p1

    .line 41
    :cond_5
    new-instance p1, Ljava/lang/IllegalStateException;

    const-string p2, "MediaExtractorWrapper has not been prepared"

    invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public declared-synchronized a()Landroid/media/MediaFormat;
    .locals 7

    monitor-enter p0

    .line 5
    :try_start_0
    iget-boolean v0, p0, Les/u9;->e:Z

    if-nez v0, :cond_5

    .line 6
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_4

    .line 7
    :try_start_1
    iget-boolean v0, p0, Les/u9;->d:Z

    if-eqz v0, :cond_0

    const-string v0, "audio/"

    goto :goto_0

    :cond_0
    const-string v0, "video/"

    .line 8
    :goto_0
    iget-object v1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    iget-object v2, p0, Les/u9;->c:Ljava/lang/String;

    invoke-virtual {v1, v2}, Landroid/media/MediaExtractor;->setDataSource(Ljava/lang/String;)V

    .line 9
    iget-object v1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {v1}, Landroid/media/MediaExtractor;->getTrackCount()I

    move-result v1

    const/4 v2, 0x0

    const/4 v3, 0x0

    :goto_1
    if-ge v3, v1, :cond_3

    .line 10
    iget-object v4, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {v4, v3}, Landroid/media/MediaExtractor;->getTrackFormat(I)Landroid/media/MediaFormat;

    move-result-object v4

    const-string v5, "mime"

    .line 11
    invoke-virtual {v4, v5}, Landroid/media/MediaFormat;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    .line 12
    invoke-virtual {v5, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_2

    const-string v0, "mewer"

    .line 13
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "prepare format:"

    invoke-virtual {v1, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/esfile/screen/recorder/media/util/k;->c(Ljava/lang/String;Ljava/lang/String;)V

    .line 14
    iget-object v0, p0, Les/u9;->b:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    :goto_2
    const/4 v0, 0x3

    if-ge v2, v0, :cond_1

    .line 15
    iget-object v0, p0, Les/u9;->b:Ljava/util/List;

    new-instance v1, Lcom/esfile/screen/recorder/media/util/l;

    const-string v5, "max-input-size"

    const/16 v6, 0x400

    .line 16
    invoke-static {v4, v5, v6}, Lcom/esfile/screen/recorder/media/util/s;->a(Landroid/media/MediaFormat;Ljava/lang/String;I)I

    move-result v5

    .line 17
    invoke-static {v5}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;

    move-result-object v5

    new-instance v6, Landroid/media/MediaCodec$BufferInfo;

    invoke-direct {v6}, Landroid/media/MediaCodec$BufferInfo;-><init>()V

    invoke-direct {v1, p0, v5, v6}, Lcom/esfile/screen/recorder/media/util/l;-><init>(Lcom/esfile/screen/recorder/media/util/m;Ljava/nio/ByteBuffer;Landroid/media/MediaCodec$BufferInfo;)V

    invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    add-int/lit8 v2, v2, 0x1

    goto :goto_2

    .line 18
    :cond_1
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {v0, v3}, Landroid/media/MediaExtractor;->selectTrack(I)V

    .line 19
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    iget-wide v1, p0, Les/u9;->g:J

    iget v3, p0, Les/u9;->i:I

    invoke-virtual {v0, v1, v2, v3}, Landroid/media/MediaExtractor;->seekTo(JI)V

    const/4 v0, 0x1

    .line 20
    iput-boolean v0, p0, Les/u9;->f:Z
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 21
    monitor-exit p0

    return-object v4

    :cond_2
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    :catch_0
    move-exception v0

    .line 22
    :try_start_2
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    :cond_3
    const/4 v0, 0x0

    .line 23
    monitor-exit p0

    return-object v0

    .line 24
    :cond_4
    :try_start_3
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "MediaExtractorWrapper has been released"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 25
    :cond_5
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "MediaExtractorWrapper is working"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    :catchall_0
    move-exception v0

    monitor-exit p0

    goto :goto_4

    :goto_3
    throw v0

    :goto_4
    goto :goto_3
.end method

.method public declared-synchronized a(Lcom/esfile/screen/recorder/media/util/l;Z)V
    .locals 0

    monitor-enter p0

    .line 1
    :try_start_0
    iget-object p2, p1, Lcom/esfile/screen/recorder/media/util/l;->b:Ljava/nio/ByteBuffer;

    invoke-virtual {p2}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;

    .line 2
    iget-object p2, p0, Les/u9;->b:Ljava/util/List;

    invoke-interface {p2, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 3
    invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 4
    monitor-exit p0

    return-void

    :catchall_0
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public a(Les/u9$a;)V
    .locals 0

    .line 42
    iput-object p1, p0, Les/u9;->k:Les/u9$a;

    return-void
.end method

.method public declared-synchronized b()V
    .locals 2

    monitor-enter p0

    .line 1
    :try_start_0
    iget-boolean v0, p0, Les/u9;->f:Z

    if-eqz v0, :cond_2

    .line 2
    iget-object v0, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    if-eqz v0, :cond_1

    .line 3
    iget-boolean v0, p0, Les/u9;->e:Z

    if-eqz v0, :cond_0

    const-string v0, "mewer"

    const-string v1, "MediaExtractorWrapper is working"

    .line 4
    invoke-static {v0, v1}, Lcom/esfile/screen/recorder/media/util/k;->d(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 5
    monitor-exit p0

    return-void

    :cond_0
    const/4 v0, 0x1

    .line 6
    :try_start_1
    iput-boolean v0, p0, Les/u9;->j:Z

    .line 7
    iput-boolean v0, p0, Les/u9;->e:Z

    .line 8
    new-instance v0, Ljava/lang/Thread;

    const-string v1, "ExtractTask"

    invoke-direct {v0, p0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 9
    monitor-exit p0

    return-void

    .line 10
    :cond_1
    :try_start_2
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "MediaExtractorWrapper has been released"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 11
    :cond_2
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "MediaExtractorWrapper has not been prepared"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public run()V
    .locals 10

    .line 1
    iget-object v0, p0, Les/u9;->k:Les/u9$a;

    if-eqz v0, :cond_0

    .line 2
    iget-boolean v1, p0, Les/u9;->d:Z

    invoke-interface {v0, p0, v1}, Les/u9$a;->b(Les/u9;Z)V

    .line 3
    :cond_0
    :goto_0
    :try_start_0
    iget-boolean v0, p0, Les/u9;->e:Z

    if-eqz v0, :cond_9

    const/4 v0, 0x0

    .line 4
    monitor-enter p0
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    .line 5
    :goto_1
    :try_start_1
    iget-boolean v1, p0, Les/u9;->e:Z

    if-eqz v1, :cond_1

    iget-object v1, p0, Les/u9;->b:Ljava/util/List;

    invoke-interface {v1}, Ljava/util/List;->isEmpty()Z

    move-result v1

    if-eqz v1, :cond_1

    const-wide/16 v1, 0xa

    .line 6
    invoke-virtual {p0, v1, v2}, Ljava/lang/Object;->wait(J)V

    goto :goto_1

    .line 7
    :cond_1
    iget-object v1, p0, Les/u9;->b:Ljava/util/List;

    invoke-interface {v1}, Ljava/util/List;->isEmpty()Z

    move-result v1

    const/4 v2, 0x0

    if-nez v1, :cond_2

    .line 8
    iget-object v0, p0, Les/u9;->b:Ljava/util/List;

    invoke-interface {v0, v2}, Ljava/util/List;->remove(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/esfile/screen/recorder/media/util/l;

    :cond_2
    if-eqz v0, :cond_8

    .line 9
    iget-boolean v1, p0, Les/u9;->e:Z

    if-nez v1, :cond_3

    goto :goto_5

    .line 10
    :cond_3
    iget-object v1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    iget-object v3, v0, Lcom/esfile/screen/recorder/media/util/l;->b:Ljava/nio/ByteBuffer;

    invoke-virtual {v1, v3, v2}, Landroid/media/MediaExtractor;->readSampleData(Ljava/nio/ByteBuffer;I)I

    move-result v1

    .line 11
    iget-object v3, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {v3}, Landroid/media/MediaExtractor;->getSampleTime()J

    move-result-wide v7

    .line 12
    iget-wide v3, p0, Les/u9;->h:J

    const-wide/16 v5, 0x0

    cmp-long v9, v3, v5

    if-lez v9, :cond_4

    iget-wide v3, p0, Les/u9;->h:J

    cmp-long v5, v7, v3

    if-ltz v5, :cond_4

    const/4 v6, 0x0

    goto :goto_2

    :cond_4
    move v6, v1

    :goto_2
    if-lez v6, :cond_6

    .line 13
    iput-wide v7, v0, Lcom/esfile/screen/recorder/media/util/l;->c:J

    .line 14
    iget-object v4, v0, Lcom/esfile/screen/recorder/media/util/l;->f:Landroid/media/MediaCodec$BufferInfo;

    const/4 v5, 0x0

    iget-object v1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    .line 15
    invoke-virtual {v1}, Landroid/media/MediaExtractor;->getSampleFlags()I

    move-result v1

    const/4 v3, 0x1

    and-int/2addr v1, v3

    if-eqz v1, :cond_5

    const/4 v9, 0x1

    goto :goto_3

    :cond_5
    const/4 v9, 0x0

    .line 16
    :goto_3
    invoke-virtual/range {v4 .. v9}, Landroid/media/MediaCodec$BufferInfo;->set(IIJI)V

    .line 17
    iget-object v1, p0, Les/u9;->a:Landroid/media/MediaExtractor;

    invoke-virtual {v1}, Landroid/media/MediaExtractor;->advance()Z

    .line 18
    monitor-exit p0
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 19
    :try_start_2
    iget-object v1, p0, Les/u9;->k:Les/u9$a;

    if-eqz v1, :cond_0

    .line 20
    iget-boolean v2, p0, Les/u9;->d:Z

    invoke-interface {v1, p0, v2, v0}, Les/u9$a;->a(Les/u9;ZLcom/esfile/screen/recorder/media/util/l;)V
    :try_end_2
    .catch Ljava/lang/InterruptedException; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_0

    :cond_6
    :try_start_3
    const-string v0, "mewer"

    .line 21
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    iget-boolean v2, p0, Les/u9;->d:Z

    if-eqz v2, :cond_7

    const-string v2, "audio"

    goto :goto_4

    :cond_7
    const-string v2, "video"

    :goto_4
    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v2, " saw eos."

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/esfile/screen/recorder/media/util/k;->c(Ljava/lang/String;Ljava/lang/String;)V

    .line 22
    monitor-exit p0

    goto :goto_6

    .line 23
    :cond_8
    :goto_5
    monitor-exit p0

    goto :goto_6

    :catchall_0
    move-exception v0

    .line 24
    monitor-exit p0
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    :try_start_4
    throw v0
    :try_end_4
    .catch Ljava/lang/InterruptedException; {:try_start_4 .. :try_end_4} :catch_0

    :catch_0
    nop

    .line 25
    :cond_9
    :goto_6
    invoke-direct {p0}, Les/u9;->c()V

    .line 26
    iget-object v0, p0, Les/u9;->k:Les/u9$a;

    if-eqz v0, :cond_a

    .line 27
    iget-boolean v1, p0, Les/u9;->d:Z

    invoke-interface {v0, p0, v1}, Les/u9$a;->a(Les/u9;Z)V

    :cond_a
    return-void
.end method

.method public declared-synchronized stop()V
    .locals 1

    monitor-enter p0

    .line 1
    :try_start_0
    iget-boolean v0, p0, Les/u9;->f:Z

    if-eqz v0, :cond_0

    iget-boolean v0, p0, Les/u9;->j:Z

    if-nez v0, :cond_1

    .line 2
    :cond_0
    invoke-direct {p0}, Les/u9;->c()V

    :cond_1
    const/4 v0, 0x0

    .line 3
    iput-boolean v0, p0, Les/u9;->e:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 4
    monitor-exit p0

    return-void

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method
